package com.guochenglang.www.dao.impl;

import com.guochenglang.www.dao.MemberDao;
import com.guochenglang.www.pojo.Member;
import com.guochenglang.www.util.GetTable;
import com.guochenglang.www.util.connect.JdbcUtil;

import java.sql.SQLException;
import java.util.ArrayList;

/**
 * 成员表的Dao层
 *
 * @author 郭程朗
 */
public class MemberDaoImpl implements MemberDao {
    /**
     * 表名
     */
    private static final String TABLE = GetTable.getTable(Member.class);

    public MemberDaoImpl() {
    }

    @Override
    public ArrayList<Member> memberSelect(Member member) throws SQLException, InterruptedException, IllegalAccessException, InstantiationException {
        return JdbcUtil.selectMax(TABLE, member);
    }

    @Override
    public ArrayList<Member> memberSelectByLimit(int page, int num, Member member, String order, String mode) throws SQLException, InterruptedException, IllegalAccessException, InstantiationException {
        return JdbcUtil.selectByLimit(TABLE, page, num, member, order, mode);
    }


    @Override
    public int insertMember(Member member) throws SQLException, InterruptedException, IllegalAccessException {
        return JdbcUtil.insert(TABLE, member);
    }

    @Override
    public int updateMember(Member set, Member conditions) throws SQLException, InterruptedException, IllegalAccessException {
        return JdbcUtil.update(TABLE, set, conditions);
    }

    @Override
    public int deleteMember(Member member) throws SQLException, InterruptedException, IllegalAccessException {
        return JdbcUtil.delete(TABLE, member);
    }
}
